package com.situ.hr4.w.dao;

import com.situ.hr4.pojo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface RLZYdao {

    //全查一级结构
    @Select(" select * from config_file_first_kind ")
    List<ConfigFileFirstKind> yijgqc();

    //添加一级机构
    @Insert("insert into config_file_first_kind values(#{first_kind_name},#{first_kind_salary_id},#{first_kind_sale_id}) ")
    void tjyijg(ConfigFileFirstKind fist);

    //根据id删除一级机构
    @Delete("delete config_file_first_kind where first_kind_id=#{value}")
    void scyijjg(int id);

    //根据id查询
    @Select("select * from config_file_first_kind where first_kind_id=#{value} ")
    ConfigFileFirstKind cxid(int id);

    //根据id修改
    @Update("update config_file_first_kind set first_kind_name=#{first_kind_name},first_kind_salary_id=#{first_kind_salary_id},first_kind_sale_id=#{first_kind_sale_id} where first_kind_id=#{first_kind_id}")
    void xgid(ConfigFileFirstKind fist);

    //查询一级机构和二级机构
    @Select("select first_kind_name,second_kind_id,second_kind_name,second_salary_id,second_sale_id from config_file_second_kind a inner join \n" +
            "\t\tconfig_file_first_kind b on a.first_kind_id=b.first_kind_id")
    List<Map> cxyjej();

    //添加第二机构表的信息
    @Insert("insert into config_file_second_kind values(#{second_kind_name},#{second_salary_id},#{second_sale_id},#{first_kind_id}) ")
    void tjdejg(ConfigFileSecondKind second);

    //根据id查询信息
    @Select("select second_kind_id,a.first_kind_id,first_kind_name,second_kind_id,second_kind_name,second_salary_id,second_sale_id from config_file_second_kind a inner join \n" +
            "\t\tconfig_file_first_kind b on a.first_kind_id=b.first_kind_id where second_kind_id=#{value}")
    Map cxid1(int id);

    //根据id修改信息进入二级机构表中
    @Update("update config_file_second_kind set second_kind_name=#{second_kind_name},\n" +
            "second_salary_id=#{second_salary_id},second_sale_id=#{second_sale_id},\n" +
            "first_kind_id=#{first_kind_id} where second_kind_id=#{second_kind_id}")
    void xgid1(ConfigFileSecondKind second);

    //根据id删除二级机构的信息
    @Delete("delete config_file_second_kind where second_kind_id=#{value}")
    void sc1(int id);

    //三表联查
    @Select("select  c.second_kind_id,c.third_kind_id,third_kind_name,third_kind_sale_id,\n" +
            "\t\tthird_kind_is_retail,a.first_kind_id,first_kind_name,second_kind_name \n" +
            "\t\tfrom config_file_second_kind a inner join config_file_first_kind b \n" +
            "\t\ton a.first_kind_id=b.first_kind_id inner join config_file_third_kind c \n" +
            "\t\ton c.second_kind_id=a.second_kind_id")
    List<Map> qc();

    @Insert("insert into config_file_third_kind values(#{second_kind_id},#{third_kind_name}\n" +
            ",#{third_kind_sale_id},#{third_kind_is_retail})")
    void tj(ConfigFileThirdKind thire);

    //根据id查询详细信息
    @Select("select  c.second_kind_id,c.third_kind_id,third_kind_name,third_kind_sale_id,\n" +
            "\t\tthird_kind_is_retail,a.first_kind_id,first_kind_name,second_kind_name \n" +
            "\t\tfrom config_file_second_kind a inner join config_file_first_kind b \n" +
            "\t\ton a.first_kind_id=b.first_kind_id inner join config_file_third_kind c \n" +
            "\t\ton c.second_kind_id=a.second_kind_id where third_kind_id=#{value}")
    Map cxxq(int id);

    //根据id修改
    @Update("update config_file_third_kind set third_kind_sale_id=#{third_kind_sale_id},third_kind_is_retail=#{third_kind_is_retail} where third_kind_id=#{third_kind_id}")
    void xgid2(ConfigFileThirdKind thire);

    //根据id删除
    @Delete("delete config_file_third_kind where third_kind_id=#{value}")
    void sc2(int id);

    @Select("select * from config_major_designation")
    List<ConfigMajorDesignation> zwmcqc();

    //根据id删除
    @Delete("delete config_major_designation where cmd_id=#{value}")
    void sczwmc(int id);

    //职位分类全查
    @Select("select * from config_major_kind")
    List<ConfigMajorKind> zwflqc();

    //添加职位分类
    @Insert("insert into config_major_kind values(#{major_kind_name})")
    void tjzwfl(ConfigMajorKind cmk);

    //根据id删除职位分类
    @Delete("delete config_major_kind where major_kind_id=#{value}")
    void sczwfl(int id);

    //全查职位设置
    @Select("select major_id,major_name,a.major_kind_id,test_amount,major_kind_name from config_major a inner join config_major_kind b\n" +
            "\ton a.major_kind_id=b.major_kind_id")
    List<Map> qczwsz();

    //添加职位设置
    @Insert("insert into config_major(major_name,major_kind_id) values(#{major_name},#{major_kind_id})")
    void tjzwsz(ConfigMajor cm);

    //根据id删除职位设置
    @Delete("delete config_major where major_id=#{value}")
    void sczwsz(int id);


    //全查公共属性设置
    @Select("select * from dbo.config_public_char")
    List<ConfigPublicChar> qcggsx();

    //添加公共属性
    @Insert("insert into dbo.config_public_char values(#{attribute_kind},#{ attribute_name})\n")
    void tjggsx(ConfigPublicChar cpc);

    //根据id删除公共属性
    @Delete("delete dbo.config_public_char where pbc_id=#{value}")
    void scggsx(int id);
}
